package tongwentongshu.com.app.fragment;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import tongwentongshu.com.app.MapMainActivity;
import tongwentongshu.com.app.R;
import tongwentongshu.com.app.db.Cache;

/**
 * Created by XiongBin on 2017/7/12.
 */

public class BootPageFragment extends Fragment {
    public Activity mActivity;
    public View mReadView;
    public String userId;
    String index;

    ImageView btn;

    public BootPageFragment(Activity activity) {
        mActivity = activity;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        Bundle args = getArguments();
        index = args != null ? args.getString(Cache.INDEX) : "";
        super.onCreate(savedInstanceState);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mReadView = initView();
        initData();
        return mReadView;
    }

    // 初始化布局,必须子类实现
    public View initView() {
        View view = View.inflate(mActivity, R.layout.fragment_boot_page, null);
        RelativeLayout start = (RelativeLayout) view.findViewById(R.id.rel_start);
        btn = (ImageView) view.findViewById(R.id.iv_start);
        switch (index) {
            case "1":
                start.setBackgroundResource(R.mipmap.guide_1);
                break;
            case "2":
                start.setBackgroundResource(R.mipmap.guide_2);
                break;
            case "3":
                start.setBackgroundResource(R.mipmap.guide_3);
                break;
            case "4":
                start.setBackgroundResource(R.mipmap.guide_4);
                btn.setVisibility(View.VISIBLE);
                break;
            default:
                break;
        }
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), MapMainActivity.class));
                getActivity().finish();
            }
        });
        return view;
    }

    // 初始化数据
    public void initData() {
    }

}
